package net.wanho.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import net.wanho.entity.User;
import net.wanho.service.UserService;
import net.wanho.vo.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author：汤小洋
 * Date：2024-12-18 9:47
 * Description：<描述>
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping("/page")
    public AjaxResult page(@RequestParam(defaultValue = "1") int pageNum,
                           @RequestParam(defaultValue = "5") int pageSize){
        PageInfo<User> pageInfo = userService.page(pageNum, pageSize);
        return AjaxResult.success(pageInfo);
    }

    @GetMapping("/register")
    public AjaxResult register(User user){
        userService.register(user);
        return AjaxResult.success();
    }

}
